Skip to content

reject too-short PROXY v2 address length in mod_remoteip#683

Open
arshsmith1 wants to merge 1 commit into
apache:trunkfrom
arshsmith1:remoteip-v2-len-check
Open

reject too-short PROXY v2 address length in mod_remoteip#683
arshsmith1 wants to merge 1 commit into
apache:trunkfrom
arshsmith1:remoteip-v2-len-check

Conversation

@arshsmith1

Copy link
Copy Markdown

remoteip_process_v2_header only bounds the advertised v2 header length from above, so a peer sending a TCPv4 or TCPv6 family with a length shorter than its address block makes the code read past what was actually received from the uninitialized ctx->header buffer and adopt those bytes as the client IP used for logging and Require ip decisions. Reject the header when ntohs(hdr->v2.len) is smaller than the family address struct, matching the existing too-long check right beside it.

Comment thread modules/metadata/mod_remoteip.c Outdated
switch (hdr->v2.fam) {
case 0x11: /* TCPv4 */
if (ntohs(hdr->v2.len) < sizeof(hdr->v2.addr.ip4)) {
ap_log_cerror(APLOG_MARK, APLOG_ERR, 0, c, APLOGNO(10595)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use APLOGNO() and let a maintainer fill in the next number as appropriate to avoid conflicts.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, both are bare APLOGNO() now and I dropped the next-number bump so the file isn't touched at all.

Your concern was well founded, by the way: trunk has moved to 10597 since I opened this, and 10596 is now taken by mod_cern_meta.c, so my hardcoded number would have collided exactly as you describe.

Comment thread modules/metadata/mod_remoteip.c Outdated
case 0x21: /* TCPv6 */
#if APR_HAVE_IPV6
if (ntohs(hdr->v2.len) < sizeof(hdr->v2.addr.ip6)) {
ap_log_cerror(APLOG_MARK, APLOG_ERR, 0, c, APLOGNO(10596)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, this one's bare APLOGNO() too.

@arshsmith1
arshsmith1 force-pushed the remoteip-v2-len-check branch from d1b4b70 to aa6c438 Compare July 17, 2026 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants